﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Collections;
using GPCSC.Web;
using NickLee.Web.UI;
using NickLee.Common;
using System.Text;
using GPCSC.Model;

namespace GPCSC.Web
{
    public partial class left : PageBase
    {
        public StringBuilder innerHTML = new StringBuilder();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                buildtopMenu();
            }
        }
        protected void buildtopMenu()
        {
            try
            {
                byte[] userInfo = (byte[])base.o_baseTable[c_obj.s_userInfo];
                Hashtable userInfoTable = CompressData.UnCompressHashtable(userInfo);
                Model.CL_Menu_S[] UserMenus = (Model.CL_Menu_S[])userInfoTable["SYS_UserMenu"];
                int j = UserMenus.Length;
                    for (int i = 0; i < j; i++)
                    {
                        Model.CL_Menu_S menu1 = UserMenus[i];

                        if (menu1.CL_PARMenuID_PK.ToString() == "00000000-0000-0000-0000-000000000000")
                        {
                            innerHTML.Append("<table width=\"177\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"><tr><td height=\"5\"></td></tr><tr onclick='shhi(\""+i.ToString()+"\")'><td  height=\"26\" class=\"text2\" style=\"background:url(Images/left.gif) no-repeat\">");
                            innerHTML.Append(menu1.MenuName.ToString());
                            innerHTML.Append("</td></tr>");
                            for (int s = 0; s < j; s++)
                            {
                                Model.CL_Menu_S menu2 = UserMenus[s];
                                if (menu2.CL_PARMenuID_PK.ToString() == menu1.CL_Menu_SOID.ToString())
                                {
                                    for (int m = 0; m < j; m++)
                                    {
                                        Model.CL_Menu_S menu3 = UserMenus[m];
                                        if (menu3.CL_PARMenuID_PK.ToString() == menu2.CL_Menu_SOID.ToString())
                                        {
                                            if (menu3.NavigateUrl.ToString() == "SHFW/SYS_STZ.aspx")
                                            {
                                                int count = 0;
                        
                                             CL_USER_S users = (GPCSC.Model.CL_USER_S)userInfoTable["SYS_USER"];
                                             DataSet ds = new GPCSC.Web.SHFW.CL_TZ_S().TzBoundS(users.CL_USER_SOID.ToString(), "0");
                                             if (ds.Tables.Count > 0)
                                             {
                                                 if (ds.Tables[0].Rows.Count > 0)
                                                 {
                                                     count = ds.Tables[0].Rows.Count;
                                                 }
                                             }
                                                innerHTML.Append(" <tr class=\"onclass\" play=\"true\" group='tr" + i.ToString() + "'><td height=\"29\" style=\"background:url(Images/left2.gif) no-repeat; cursor:pointer;\"><table width=\"177\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" onclick=\"shAndhi('" + menu3.NavigateUrl + "',this)\"><tr><td ids=\"true\" class=\"text3\">" + menu3.MenuName + "("+count.ToString()+")</td></tr></table></td></tr>");
                                            }
                                            else
                                            {
                                                innerHTML.Append(" <tr class=\"onclass\" play=\"true\" group='tr" + i.ToString() + "'><td height=\"29\" style=\"background:url(Images/left2.gif) no-repeat; cursor:pointer;\"><table width=\"177\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" onclick=\"shAndhi('" + menu3.NavigateUrl + "',this)\"><tr><td ids=\"true\" class=\"text3\">" + menu3.MenuName + "</td></tr></table></td></tr>");
                                            }
                                        }
                                    }
                                }
                            }
                            innerHTML.Append("</table>");
                        }
                    }
                    Model.CL_ROLE_S UserRole = (Model.CL_ROLE_S)userInfoTable["SYS_userRole"];
                    mrsy.Value = UserRole.MRSY.ToString();
                    if (Usual.f_querystringToString("tz") != "" && Usual.f_querystringToString("tz") != null)
                    {
                        tz.Value = Usual.f_querystringToString("tz");
                    }
            }
            catch (Exception ee)
            {
                throw ee;
            }
        }

    }
}